<?php
/**
 * Created by PhpStorm.
 * User: Jerry
 * Date: 2016/12/3
 * Time: 9:12
 */

namespace SDXApi\Model;


use ClassesWithParents\E;
use Think\Model;

/**
 * Class OperateLogModel
 * @package SDXApi\Model
 */
class OperateLogModel extends Model
{
	/**
	 * @var string
	 */
	protected $tableName = 'operate_log';


	/**
	 * 插入促销价商品
	 * Created by Jerry
	 * @param $goods
	 * @return bool|mixed
	 */
	public function insert_sales_goods_for_operate($goods)
	{
		if (empty($goods)) {
			return false;
		}

		$data = array(
			'goods_sn'	=>	$goods['goods_sn'],
			'goods_id'	=>	$goods['goods_id'],
			'goods_name'=>	$goods['goods_name'],
			'type'		=>	$goods['type'],
		);

		try{
			return $this->add($data);
		}catch (\Exception $exception){
			E('插入失败');
		}
	}

	/**
	 * 批量插入预警日志
	 * Created by Jerry
	 * @param $goods
	 * @return bool
	 */
	public function insert_sales_goods_for_operate_all($goods)
	{
		if (empty($goods)) {
			return false;
		}

		foreach ($goods as $k => $v) {
			if (empty($v)) {
				continue;
			}
			try{
				$this->addAll($v);
			}catch (\Exception $exception) {
				E('插入失败');
			}

		}
	}

	/**
	 * 插入所有数据
	 * Created by Jerry
	 * @param array $data
	 * @return bool|string
	 */
	public function insertOperateLogGoodsAll($data = array())
	{
		if (empty($data)) {
			return false;
		}

		try{
			return $this->addAll($data);
		}catch (\Exception $exception){
			E('插入失败');
		}
	}


	/**
	 * 删除促销产品类型
	 * Created by Jerry
	 * @param $where
	 * @return mixed
	 */
	public function detele_operate_by_sales_type($where)
	{
		return $this->where($where)->delete();
	}
}